@extends('admin.main')
@section('content')
    <div class="admin-biaogelist">
        <div class="daohang">
            <ul>
                <li>
                    <button type="button" class="am-btn am-btn-default am-radius am-btn-xs"> 医师坐诊管理</button>
                </li>
            </ul>
        </div>
        <div class="listbiaoti am-cf">
            <ul class="am-icon-flag on"> 医师坐诊时间</ul>

            <dl class="am-icon-home" style="float: right;"> 当前位置： 首页 > <a href="#">医师坐诊时间列表</a></dl>
            <dl>
                <button type="button" class="am-btn am-btn-danger am-round am-btn-xs am-icon-plus"
                        onclick="window.location.href='{{urlAdmin('doctor','getAddWorkTime')}}?id={{$_GET['id']}}'"> 添加坐诊时间段
                </button>
            </dl>
        </div>

        <form class="am-form am-g">
            <table width="100%" class="am-table am-table-bordered am-table-radius am-table-striped">
                <thead>
                <tr class="am-success">
                    <th class="table-type" width="10%">日期</th>
                    <th class="table-author" width="10%">预约类型</th>
                    <th class="table-date am-hide-sm-only" width="15%">坐诊时段</th>
                    <th class="table-date am-hide-sm-only">安排时间</th>
                    <th width="20%" class="table-set">操作</th>
                </tr>
                </thead>
                <tbody>
                @if(!empty($res['data']))
                    @foreach($res['data'] as $v)
                        <tr id="tr_{{$v['id']}}">
                            <td>{{$v['add_time']}}</td>
                            <td class="am-hide-sm-only"><span @if($v['apointment_type']==1)class="btn_show active"@else class="btn_show"@endif>门诊</span><span  @if($v['apointment_type']==2)class="btn_show active"@else class="btn_show"@endif>电话</span></td>
                            <td class="am-hide-sm-only"><span @if($v['apointment_type']==1)class="btn_show active"@else class="btn_show"@endif>全天</span><span  @if($v['apointment_type']==2)class="btn_show active"@else class="btn_show"@endif>上午</span><span  @if($v['apointment_type']==3)class="btn_show active"@else class="btn_show"@endif>下午</span></td>
                            <th class="table-date" style="color: #666">
                                @if (isset($v['time_arr']))
                                @if(count($v['time_arr'])==14)
                                     满排
                                @else
                                @foreach($v['time_arr'] as $value)
                                    <span class="btn_show active">{{$value}}</span>
                                @endforeach
                                @endif
                                @endif
                            </th>
                            <td width="15%">@if($v['status']==0)<a href="javascript:void(0)" onclick="op(this,{{$v['id']}},1)" class="abtn">开启</a> @else <a href="javascript:void(0)" onclick="op(this,{{$v['id']}},0)" class="abtn">暂停</a> @endif<a href="{{urlAdmin('doctor','getEditWorkTime')}}?id={{$v['id']}}" class="abtn ff6600">编辑</a><a href="javascript:void(0)" onclick="del({{$v['id']}})" class="abtn ff6600">删除</a> </td>
                        </tr>
                     @endforeach
                @endif
                </tbody>
            </table>
            <ul class="am-pagination am-fr">
                @if(isset($res['prev_page_url']))
                    <li><a href="$res['prev_page_url']">«</a></li>
                @endif
                @foreach($res['pageNoList'] as $v)
                    @if($res['current_page']==$v)
                        <li class="am-active"><a href="{{urlAdmin("doctor",'getWorkTimeList')}}?id={{$_GET['id']}}&page={{$v}}">{{$v}}</a></li>
                    @else
                        <li><a href="{{urlAdmin("doctor",'getWorkTimeList')}}?id={{$_GET['id']}}&page={{$v}}">{{$v}}</a></li>
                    @endif
                @endforeach
                    @if($res['next_page_url'])
                        <li><a href="{{$res['next_page_url']}}">»</a></li>
                    @endif
            </ul>
    @include('admin.footer')
            @section('script')
                <script>
                    function op(_this,id,ver) {
                        if (ver==1){
                            str = '开启';
                        }else{
                            str = '暂停';
                        }
                        layer.confirm('您确定要'+str+'吗？', {
                            btn: ['确定', '取消'] //按钮
                        }, function () {
                            $.ajax({
                                type: "get",
                                url: "{{urlAdmin('doctor','getChangeState')}}?id=" + id+"&status="+ver,
                                dataType: "json",
                                success: function (res) {
                                    if (res['state'] == 1) {
                                        layer.msg('操作成功', {icon: 6}, function () {
                                            if(ver==1) {
                                                _this.innerHTML = "暂停";
                                            }
                                            if(ver==0) {
                                                _this.innerHTML = "开启";
                                            }
                                        });
                                    } else {
                                        layer.msg('操作失败', {icon: 5});
                                    }
                                }
                            })
                        });
                    }

                    function del(id) {
                        layer.confirm('您确定要删除吗？', {
                            btn: ['确定', '取消'] //按钮
                        }, function () {
                            $.ajax({
                                type: "get",
                                url: "{{urlAdmin('doctor','getDelWorkTime')}}?id=" + id,
                                dataType: "json",
                                success: function (res) {
                                    if (res['status'] == 1) {
                                        layer.msg('删除成功', {icon: 6});
                                        $('#tr_'+id).hide();
                                    } else {
                                        layer.msg('删除失败', {icon: 5});
                                    }
                                }
                            })

                        });
                    }
                </script>
@endsection
@endsection